package com.ruoyi.web.controller.EsSearch;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/employeeInfo")
public class EmployeeElasticController {

    @Autowired
    private EmployeeInfoRepository elasticRepository;

    @RequestMapping("/save")
    public String save() throws Exception {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
//        EmployeeInfo employeeInfo = new EmployeeInfo(6001L, "2001", "张三", "zhangsan", "Java", 1, 19, new BigDecimal("12500.01"), simpleDateFormat.parse("2019-09-10"), "备注");
//        elasticRepository.save(employeeInfo);
        return "success";
    }

//    @RequestMapping("/saveAll")
//    public String saveAll() throws Exception {
//        List<UserInfo> list = new ArrayList<>();
//        Map<String,String> user = new HashMap<>();
//        user.put("id","1e58445b6301439bbe4caa8bf6474918");
//        user.put("accout","wangguangmei");
//        user.put("realName","王光美");
//        user.put("phone","189509406870");
//        user.put("email","189509406870@189.com");
//        list.add( UserInfo("123123","guoguo","杨宝庆","2024-11-30 20:50:30","user","123123"."");
//        elasticRepository.saveAll(list);
//        return "success -> " + list.size();
//    }
//
//    @RequestMapping("/findByAgeBetween")
//    public String findByAgeBetween(){
//        elasticRepository.findByAgeBetween(10,20);
//        return "success";
//    }
}